package com.gsit.netlog.test;

import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;

public class Selenium2Example {

	public static void main(String[] args) {
		WebDriver driver = new InternetExplorerDriver();
		
		 WebDriverWait wait = new WebDriverWait(driver, 30);  
		 List<WebElement> anchorTags = driver.findElements(By.tagName("a"));
             for(WebElement table2: anchorTags){
               String hrfStr = table2.getAttribute("href");
               System.out.println("href: "+ hrfStr);
           }

		driver.get("http://photospy.netnoc.eu/moderate/?view=pictures&type=NORMAL");
        WebElement element = driver.findElement(By.name("q"));
        
        element.sendKeys("Cheese!");
        element.submit();
        System.out.println("Page title is: " + driver.getTitle());
        new WebDriverWait(driver, 10).until(new ExpectedCondition<Boolean>() {
            public Boolean apply(WebDriver d) {
                return d.getTitle().toLowerCase().startsWith("cheese!");
            }
        });
        System.out.println("Page title is: " + driver.getTitle());
        driver.quit();
        

	}

}
